package com.ruoyi.mall.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.mall.entity.MallCoupons;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mall.mapper.MallCouponsMapper;
import com.ruoyi.mall.service.IMallCouponsService;
import com.ruoyi.common.core.text.Convert;

/**
 * 优惠劵Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-05-25
 */
@Service
public class MallCouponsServiceImpl implements IMallCouponsService 
{
    @Autowired
    private MallCouponsMapper mallCouponsMapper;

    /**
     * 查询优惠劵
     * 
     * @param couponsId 优惠劵ID
     * @return 优惠劵
     */
    @Override
    public MallCoupons selectMallCouponsById(Long couponsId)
    {
        return mallCouponsMapper.selectMallCouponsById(couponsId);
    }

    /**
     * 查询优惠劵列表
     * 
     * @param mallCoupons 优惠劵
     * @return 优惠劵
     */
    @Override
    public List<MallCoupons> selectMallCouponsList(MallCoupons mallCoupons)
    {
        return mallCouponsMapper.selectMallCouponsList(mallCoupons);
    }

    /**
     * 新增优惠劵
     * 
     * @param mallCoupons 优惠劵
     * @return 结果
     */
    @Override
    public int insertMallCoupons(MallCoupons mallCoupons)
    {
        mallCoupons.setCreateTime(DateUtils.getNowDate());
        return mallCouponsMapper.insertMallCoupons(mallCoupons);
    }

    /**
     * 修改优惠劵
     * 
     * @param mallCoupons 优惠劵
     * @return 结果
     */
    @Override
    public int updateMallCoupons(MallCoupons mallCoupons)
    {
        mallCoupons.setUpdateTime(DateUtils.getNowDate());
        return mallCouponsMapper.updateMallCoupons(mallCoupons);
    }

    /**
     * 删除优惠劵对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMallCouponsByIds(String ids)
    {
        return mallCouponsMapper.deleteMallCouponsByIds(Convert.toStrArray(ids));
    }
    /**
     * 优惠劵包ID查优惠劵信息
     *
     * @param packageId 优惠劵包ID
     * @return 结果
     */
    @Override
    public List<MallCoupons> selectMallCouponsByPackageId(Long packageId) {
        return mallCouponsMapper.selectMallCouponsByPackageId(packageId);
    }

    /**
     * 删除优惠劵信息
     * 
     * @param couponsId 优惠劵ID
     * @return 结果
     */
    @Override
    public int deleteMallCouponsById(Long couponsId)
    {
        return mallCouponsMapper.deleteMallCouponsById(couponsId);
    }
}
